{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Shor Algorithm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "\n",
    "%matplotlib inline\n",
    "import numpy as np\n",
    "from numpy import fft\n",
    "from math import gcd\n",
    "import time\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "def f(x,a,N):\n",
    "    return a**x % N\n",
    "\n",
    "p = 17\n",
    "q = 29\n",
    "N = p*q\n",
    "a = 22\n",
    "print(gcd(N,a))\n",
    "\n",
    "table = np.array([f(x,a,N) for x in range(262144)])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "22 6\n",
      "6 4\n",
      "4 2\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def gcd1(a,b):\n",
    "    while b:\n",
    "        print(a,b)\n",
    "        a,b = b,a%b\n",
    "    return a\n",
    "gcd1(22,6)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAOX0lEQVR4nO3df6zddX3H8edrVKcgEVjPGBPuLtuwhhn5kRvF6ZyCms4S2R/+IRkGN5abLOpwYSNlJjP7Y0m3GX8kW1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cChysqt2zrqUnr6+qC1laMn1Pkjcsf7KhY2wDcCHw8aq6APghQ8sl0/TSUoAfj5fufy/JGQDd94MzrmcsSV7AUnjfUFU3dcNN9vKcqvo+8DWWlhlOSfLcRW6tHGevA96eZD9LPxn0YpbWXlvshap6vPt+EPg8S/+4tniMHQAOVNWd3faNLAV6L720FODH46X7XwKu7B5fydJ68rqWJMAngX1V9eFlT7XYyyDJKd3jF7O0lr+PpSB/R7dbE71U1XVVdWZVzbP0d+OrVfU7NNhLkpOSnPzcY+CtwF4aPMaq6kngsSSbuqFLgAfoq5dZL/Kv8g2BtwHfZmmd8gOzrmeVte8EngB+zNK/ylextEZ5O/Aw8M/AabOuc4w+Xs/Sf/e+Bezpvt7WaC+vAu7petkL/Fk3/svAXcAjwD8CPzvrWlfZ1xuBm1vtpav53u7r/uf+rrd4jHV1nw/s6o6zLwCn9tWLl9JLUqNaWkKRJC1jgEtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RG/T/HkoJ3JNnb4AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "a = 11\n",
    "N = 21\n",
    "f = np.array([a**x % N for x in range(512)])\n",
    "plt.bar(range(60),f[0:60])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXSc9X3v8fdXs2i0y5JlySs2WDZLICwuUEgIgZYtPYH0UgKnOdCUHHIbkqYhbUq6XNL25Dbp7S1t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xc0y/3U1W/IzO4GziUz1fQQcBPwA2b4TrwHkC+TqXaNAh92zm2e8xoLJRCIiEhxFlrVkIiIFEiBQERkkVMgEBFZ5BQIREQWOQUCEZFFToFARGSRUyAQEVnk/j8ct5YoaNpOkQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(70,100),np.abs(fft.fft(f)[70:100]))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6.023529411764706"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r = 512/85\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
